<template>
  <el-select
    v-model="userId"
    filterable
    remote
    reserve-keyword

    placeholder="请输入关键词"
    :remote-method="getList"
    @change="change"
    :loading="loading">

    <el-option
      v-for="item in userList"
      :key="item.id"
      :label="item.phone"
      :value="item.id">
    </el-option>
  </el-select>
</template>

<script>

import { seekUserList } from "@/api/car/seekUser";
export default {
  name: 'UserSearch',
  props: ['value'],
  data() {
    return {
      userList:[],
      loading:false,
      userId: null
    }
  },
  methods: {
    getList(query) {
     this.loading=true;
      seekUserList(query).then(res => {
        this.userList = res.data;
        this.loading=false;
      })
    },
    change(value){
     if (value){
       this.$emit('input',value)
     }
    }

  }
}
</script>

<style lang="scss" scoped>

</style>
